package com.desyang.server.provider;

import java.util.HashMap;

public class ServiceProvider {
    HashMap<String, Object> services = new HashMap<>();

    public void register(Object service) {
        Class<?>[] interfaces = service.getClass().getInterfaces();
        for (Class<?> clazz : interfaces) {
            services.put(clazz.getName(), service);
        }
    }

    public Object getService(String serviceName) {
        return services.get(serviceName);
    }
}
